<template>
  <div class="login">
    <div class="content">
      <div class="left">
        <!-- <img class="logo" src="../../assets/images/login_logo.png" alt=""> -->
      </div>
      <div class="right">
        <div class="title">用户登录</div>
        <el-form class="form" :model="loginData" label-position="left">
          <div class="topWrapper">
            <div>
              <div class="list">
                <el-form-item>
                  <el-input v-model.trim="loginData.userNameOrPhone" placeholder="账号" clearable>
                    <template #suffix>
                      <!-- <img src="../../assets/images/login_user.png" alt=""> -->
                    </template>
                  </el-input>
                </el-form-item>
              </div>
              <div class="list">
                <el-form-item>
                  <el-input type="password" v-model.trim="loginData.password" placeholder="密码" clearable>
                    <template #suffix>
                      <!-- <img src="../../assets/images/login_password.png" alt=""> -->
                    </template>
                  </el-input>
                </el-form-item>
              </div>
            </div>
          </div>
        </el-form>
        <div class="btn">
          <el-button type="warning" @click="toLogin">登 录</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { getTokenApi} from "@/http/api_hd";
import router from "@/routes/index";
import {useMain} from "../../store/index";
const loginData = reactive({
  userNameOrPhone: "", //账户名
  password: "", //密码
})

const useMainStore = useMain(); //pinia

const toLogin = ()=>{
  // router.push("/home");
  getTokenApi(loginData).then((res:any)=>{
    if(res && res.token){
      useMainStore.updatedAuthTokenHd(res.token);
      router.push("/home");
    }
  })
}

</script>
<style lang="scss">
.login {
  width: 100%;
  height: 100%;
  position: relative;
  background: rgba(0, 0, 0, 1);

  .content {
    width: 100%;
    height: 590px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    // background: url(../../assets/images/login_bg.jpg) no-repeat;
    background-size: 100% 100%;
    padding-top: 67px;
    padding-right: 11.97%;
    padding-left: 18.12%;
    display: flex;

    .left {
      flex: 1;
      padding-top: 171px;
      display: flex;

      .logo {
        width: 410px;
        height: 129px;
      }
    }

    .right {
      width: 425px;
      height: 470px;
      // background: url(../../assets/images/login_box.png) no-repeat;
      background-size: 100% 100%;
      padding: 32px 50px 28px 50px;

      .title {
        font-size: 24px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 30px;
        color: rgba(192, 164, 91, 1);
        text-align: center;
        vertical-align: top;
        margin-bottom: 33px;
      }

      .topWrapper {
        width: 100%;

        .list {
          &:last-child {
            margin: 20px 0 50px 0;
          }

          .el-form-item {
            width: 100%;
            margin-bottom: 0;

            .el-input {
              width: 100%;
              height: 60px;
              line-height: 60px;
              // background: url(../../assets/images/login_input_bg.png) no-repeat;
              background-size: 100% 100%;

              .el-input__wrapper {
                background: rgba(112, 105, 95, 0.2);
                box-shadow: none;
                padding-left: 23px;

                &.is-focus {
                  box-shadow: none;
                 border: none;
                }

                .el-input__inner {
                  font-size: 16px;
                  font-weight: 400;
                  letter-spacing: 0px;
                  line-height: 35px;
                  color: rgba(192, 164, 91, 1);

                  &::placeholder {
                    font-size: 16px;
                    font-weight: 400;
                    letter-spacing: 0px;
                    line-height: 35px;
                    color: rgba(192, 164, 91, 1);
                  }
                }
              }

              .el-input__suffix {
                height: auto;
                font-size: 20px;
                // width: 60px;

                .el-input__suffix-inner {
                  width: 100%;
                  flex-direction: row-reverse;
                  -webkit-flex-direction: row-reverse;
                  justify-content: flex-end;
                  display: flex;

                  .el-input__clear {
                    font-size: 15px;
                    color: rgba(112, 105, 95);
                    margin-right: 20px;
                  }
                }
              }
            }
          }
        }
      }



      .remember {
        display: flex;
        align-items: center;
        font-size: 13px;
        font-weight: 400;
        letter-spacing: 1px;
        line-height: 35px;
        color: rgba(114, 114, 114, 1);
        margin-bottom: 17px;

        // img {
        //   width: 20px;
        //   height: 20px;
        //   margin-right: 20px;

        //   vertical-align: text-top;
        // }
        .el-checkbox {
          margin-right: 20px;
        }
      }

      .btn {
        .el-button {
          width: 100%;
          height: 50px;
          font-size: 16px;
          font-weight: 400;
          letter-spacing: 0px;
          line-height: 50px;
          color: rgba(255, 255, 255, 1);
        }
      }

      .forget {
        margin-top: 20px;
        text-align: center;

        span {
          font-size: 13px;
          font-weight: 400;
          letter-spacing: 1px;
          line-height: 35px;
          color: rgba(114, 114, 114, 1);
          cursor: pointer;
        }
      }

    }
  }
}
</style>